flyspace-cli 0.1.63 → 0.1.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ import {
30
30
  sweepScratchDir,
31
31
  uploadLocalImages,
32
32
  useHostDbWithoutCredentials
33
- } from "./chunk-UZMHXV4D.js";
33
+ } from "./chunk-O7OYNQND.js";
34
34
 
35
35
  // ../../node_modules/.pnpm/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
36
36
  var require_delayed_stream = __commonJS({
@@ -8832,7 +8832,7 @@ var require_mime_types = __commonJS({
8832
8832
  "../../node_modules/.pnpm/mime-types@2.1.35/node_modules/mime-types/index.js"(exports) {
8833
8833
  "use strict";
8834
8834
  var db = require_mime_db();
8835
- var extname3 = __require("path").extname;
8835
+ var extname4 = __require("path").extname;
8836
8836
  var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
8837
8837
  var TEXT_TYPE_REGEXP = /^text\//i;
8838
8838
  exports.charset = charset;
@@ -8886,7 +8886,7 @@ var require_mime_types = __commonJS({
8886
8886
  if (!path || typeof path !== "string") {
8887
8887
  return false;
8888
8888
  }
8889
- var extension2 = extname3("x." + path).toLowerCase().substr(1);
8889
+ var extension2 = extname4("x." + path).toLowerCase().substr(1);
8890
8890
  if (!extension2) {
8891
8891
  return false;
8892
8892
  }
@@ -18556,10 +18556,17 @@ function sessionUserId(cookies) {
18556
18556
  }
18557
18557
  }
18558
18558
  var isScoped = (name) => name.startsWith(SCOPE_MARK);
18559
+ var isSession = (c) => SESSION_NAME.test(c.name);
18560
+ function hasCorruptSession(cookies) {
18561
+ const session = cookies.filter((c) => isSession(c) && c.value !== "");
18562
+ return session.length > 0 && sessionUserId(session) === null;
18563
+ }
18559
18564
  function readScopedCookies(all, label) {
18560
18565
  const prefix = scopePrefix(label);
18561
18566
  const own = all.filter((c) => c.name.startsWith(prefix)).map((c) => ({ name: c.name.slice(prefix.length), value: c.value }));
18562
- return own.length ? own : all.filter((c) => !isScoped(c.name));
18567
+ if (own.length && !hasCorruptSession(own)) return own;
18568
+ const shared = all.filter((c) => !isScoped(c.name));
18569
+ return hasCorruptSession(shared) ? shared.filter((c) => !isSession(c)) : shared;
18563
18570
  }
18564
18571
  function routeCookieWrites(all, label, writes) {
18565
18572
  const prefix = scopePrefix(label);
@@ -21822,6 +21829,12 @@ var featureFlags = {
21822
21829
  title: "Columns view",
21823
21830
  description: "A third view next to Rounds and Board: pin up to 6 threads from any channel and read them side by side as full-height columns. Desktop only; pins are kept in this browser.",
21824
21831
  stage: "beta"
21832
+ },
21833
+ "voice-guide": {
21834
+ title: "Voice guide",
21835
+ description: "Support walks you through the UI: a Show me button under @support answers that opens the right page and spotlights what to click, and later a Talk mode that answers out loud. Speech is sent to OpenAI.",
21836
+ stage: "beta",
21837
+ operatorOnly: true
21825
21838
  }
21826
21839
  };
21827
21840
  var featureFlagIds = Object.keys(featureFlags);
@@ -23505,12 +23518,14 @@ async function runAutomation(opts) {
23505
23518
 
23506
23519
  // src/automations/script-runner.ts
23507
23520
  import { spawn as spawn3 } from "child_process";
23521
+ import { accessSync, constants } from "fs";
23508
23522
  var DEFAULT_TIMEOUT_MS = 12e4;
23509
23523
  var KILL_GRACE_MS3 = 5e3;
23510
23524
  function runScriptAutomation(opts) {
23511
23525
  const { name, script, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
23512
23526
  return new Promise((resolve8, reject) => {
23513
- const child = spawn3("/bin/bash", [script], { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
23527
+ const [cmd, args] = isExecutable(script) ? [script, []] : ["/bin/bash", [script]];
23528
+ const child = spawn3(cmd, args, { cwd, env: resolveMiseEnv(cwd), stdio: ["ignore", "pipe", "pipe"] });
23514
23529
  let stdout = "";
23515
23530
  let stderr = "";
23516
23531
  let timedOut = false;
@@ -23549,6 +23564,14 @@ function runScriptAutomation(opts) {
23549
23564
  });
23550
23565
  });
23551
23566
  }
23567
+ function isExecutable(path) {
23568
+ try {
23569
+ accessSync(path, constants.X_OK);
23570
+ return true;
23571
+ } catch {
23572
+ return false;
23573
+ }
23574
+ }
23552
23575
 
23553
23576
  // ../api/src/automations/manager.ts
23554
23577
  function findInChannels(name) {
@@ -24355,8 +24378,9 @@ function buildFilesPromptSection(result) {
24355
24378
  const parts = [];
24356
24379
  if (result.succeeded.length > 0) {
24357
24380
  const list = result.succeeded.map((f) => `- ${f.path} (${f.name}, ${f.mimetype})`).join("\n");
24381
+ const pdfHint = result.succeeded.some((f) => f.mimetype === "application/pdf") ? '\nFor a PDF over 10 pages, Read it in chunks with the `pages` parameter (max 20 pages per call, e.g. "1-20", "21-40"), or convert it with `pdftotext`. Never give up because it is too large.' : "";
24358
24382
  parts.push(`[attached files \u2014 use the Read tool to view them]
24359
- ${list}`);
24383
+ ${list}${pdfHint}`);
24360
24384
  }
24361
24385
  if (result.skipped.length > 0) {
24362
24386
  const list = result.skipped.map((f) => `- ${f.name}${f.mimetype ? ` (${f.mimetype})` : ""} \u2014 ${f.reason}`).join("\n");
@@ -25505,7 +25529,7 @@ async function withMcpConfig(profile, connectionIds, fn, extraServers = {}) {
25505
25529
 
25506
25530
  // ../api/src/version.ts
25507
25531
  import { readFileSync as readFileSync8 } from "fs";
25508
- var CLI_VERSION = true ? "0.1.63" : devVersion();
25532
+ var CLI_VERSION = true ? "0.1.65" : devVersion();
25509
25533
  function isOlderVersion(a, b) {
25510
25534
  const parse2 = (v) => v.replace(/^v/, "").split("-")[0].split(".").map(Number);
25511
25535
  const [pa, pb] = [parse2(a), parse2(b)];
@@ -27416,7 +27440,7 @@ async function offloadPluginUi(workspace, state) {
27416
27440
  var pluginUiHash = (state) => sha256(JSON.stringify(state));
27417
27441
 
27418
27442
  // src/dashboard/doc-mention-guard.ts
27419
- import { existsSync as existsSync21, statSync as statSync9 } from "fs";
27443
+ import { existsSync as existsSync21, statSync as statSync10 } from "fs";
27420
27444
 
27421
27445
  // src/dashboard/docs-routes.ts
27422
27446
  import {
@@ -27428,15 +27452,15 @@ import {
27428
27452
  openSync,
27429
27453
  readSync,
27430
27454
  readdirSync as readdirSync6,
27431
- readFileSync as readFileSync17,
27455
+ readFileSync as readFileSync18,
27432
27456
  realpathSync as realpathSync2,
27433
27457
  renameSync as renameSync3,
27434
27458
  rmSync as rmSync10,
27435
- statSync as statSync8,
27459
+ statSync as statSync9,
27436
27460
  writeFileSync as writeFileSync7
27437
27461
  } from "fs";
27438
27462
  import { Readable } from "stream";
27439
- import { basename as basename6, dirname as dirname3, extname as extname2, join as join21, relative as relative2, resolve as resolve7, sep as sep4 } from "path";
27463
+ import { basename as basename6, dirname as dirname3, extname as extname3, join as join21, relative as relative2, resolve as resolve7, sep as sep4 } from "path";
27440
27464
  import { Hono as Hono4 } from "hono";
27441
27465
  import { streamSSE } from "hono/streaming";
27442
27466
 
@@ -27616,6 +27640,257 @@ function closeEntry(cwd) {
27616
27640
  entry.watcher.close();
27617
27641
  }
27618
27642
 
27643
+ // ../api/src/dashboard/bridge-types.ts
27644
+ var SHARE_ASSET_PLACEHOLDER = "/share/{{flyspace-share-id}}/assets/";
27645
+
27646
+ // src/dashboard/doc-share-publisher.ts
27647
+ import { readFileSync as readFileSync14, statSync as statSync7 } from "fs";
27648
+ import { extname as extname2, posix } from "path";
27649
+ var MAX_ASSET_BYTES = 20 * 1024 * 1024;
27650
+ var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
27651
+ var MAX_ASSETS = 50;
27652
+ var MAX_BUNDLE_ASSET_BYTES = 48 * 1024 * 1024;
27653
+ var MAX_INLINE_BYTES = 200 * 1024;
27654
+ var MAX_TOTAL_INLINE_BYTES = 1024 * 1024;
27655
+ var MD_LINK = /(!?\[[^\]]*\]\()\s*(<[^>]+>|[^)\s]+)/g;
27656
+ var MD_LINK_FULL = /(!?)\[([^\]]*)\]\(\s*(<[^>]+>|[^)\s]+)((?:\s+"[^"]*"|\s+'[^']*'|\s+\([^)]*\))?)\s*\)/g;
27657
+ var HTML_URL_ATTR = /\b(src|href|poster)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi;
27658
+ var HTML_CSS_URL = /\burl\(\s*("[^"]*"|'[^']*'|[^)'"\s]+)\s*\)/gi;
27659
+ var HTML_URL_PATTERNS = [
27660
+ { re: HTML_URL_ATTR, group: 2 },
27661
+ { re: HTML_CSS_URL, group: 1 }
27662
+ ];
27663
+ function unquote2(value) {
27664
+ const q = value[0];
27665
+ if ((q === '"' || q === "'") && value.length >= 2 && value.endsWith(q)) {
27666
+ return { quote: q, url: value.slice(1, -1) };
27667
+ }
27668
+ return { quote: "", url: value };
27669
+ }
27670
+ function htmlUrls(source) {
27671
+ const seen = /* @__PURE__ */ new Set();
27672
+ const out = [];
27673
+ for (const { re, group } of HTML_URL_PATTERNS) {
27674
+ for (const match of source.matchAll(re)) {
27675
+ const { url } = unquote2(match[group]);
27676
+ if (!url || seen.has(url)) continue;
27677
+ seen.add(url);
27678
+ out.push(url);
27679
+ }
27680
+ }
27681
+ return out;
27682
+ }
27683
+ function rewriteHtml(source, rewritten) {
27684
+ return source.replace(HTML_URL_ATTR, (whole, attr, value) => {
27685
+ const { quote, url } = unquote2(value);
27686
+ const next = rewritten.get(url);
27687
+ return next ? `${attr}=${quote || '"'}${next}${quote || '"'}` : whole;
27688
+ }).replace(HTML_CSS_URL, (whole, value) => {
27689
+ const { quote, url } = unquote2(value);
27690
+ const next = rewritten.get(url);
27691
+ return next ? `url(${quote || '"'}${next}${quote || '"'})` : whole;
27692
+ });
27693
+ }
27694
+ var MAX_PREVIEW_INLINE_BYTES = 10 * 1024 * 1024;
27695
+ function inlinePreviewImages(cwd, sourcePath, source) {
27696
+ const docDir = posix.dirname(sourcePath) === "." ? "" : posix.dirname(sourcePath);
27697
+ const inlined = /* @__PURE__ */ new Map();
27698
+ for (const url of htmlUrls(source)) {
27699
+ const ref = classifyHref(cwd, docDir, url);
27700
+ if (ref?.kind !== "local") continue;
27701
+ const resolved2 = resolveRawPath(cwd, ref.rel);
27702
+ if (!resolved2 || !resolved2.contentType.startsWith("image/")) continue;
27703
+ try {
27704
+ if (statSync7(resolved2.abs).size > MAX_PREVIEW_INLINE_BYTES) continue;
27705
+ const data = readFileSync14(resolved2.abs).toString("base64");
27706
+ inlined.set(url, `data:${resolved2.contentType};base64,${data}`);
27707
+ } catch {
27708
+ }
27709
+ }
27710
+ return inlined.size ? rewriteHtml(source, inlined) : source;
27711
+ }
27712
+ function shareKindOf(absPath) {
27713
+ const ext = extname2(absPath).toLowerCase();
27714
+ if (ext === ".md" || ext === ".markdown") return "markdown";
27715
+ if (ext === ".html" || ext === ".htm") return "html";
27716
+ if (ext === ".excalidraw") return "excalidraw";
27717
+ return null;
27718
+ }
27719
+ function isExternalHref(href) {
27720
+ return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || href.startsWith("#");
27721
+ }
27722
+ function sanitizeAssetName(name) {
27723
+ const base = name.split(/[/\\]/).pop() ?? "";
27724
+ const cleaned = base.replace(/\s+/g, "-").replace(/[^\w.-]/g, "").trim();
27725
+ return (cleaned || "file").slice(-100);
27726
+ }
27727
+ function renderAttachments(files) {
27728
+ if (files.length === 0) return "";
27729
+ const blocks = files.map((f) => {
27730
+ const longest = Math.max(0, ...[...f.text.matchAll(/`{3,}/g)].map((m) => m[0].length));
27731
+ const fence = "`".repeat(Math.max(3, longest + 1));
27732
+ const label = f.path.replace(/["\r\n]/g, "");
27733
+ return `${fence}${f.lang} file="${label}" id=${f.anchor}
27734
+ ${f.text.replace(/\s+$/, "")}
27735
+ ${fence}`;
27736
+ });
27737
+ return `
27738
+
27739
+ ---
27740
+
27741
+ ${blocks.join("\n\n")}
27742
+ `;
27743
+ }
27744
+ function classifyHref(cwd, docDir, rawHref) {
27745
+ const href = rawHref.startsWith("<") && rawHref.endsWith(">") ? rawHref.slice(1, -1) : rawHref;
27746
+ if (!href) return null;
27747
+ const attachment = href.match(/^\/api\/attachments\/(.+)$/);
27748
+ if (attachment) {
27749
+ const key = attachment[1].split("/").map((s) => {
27750
+ try {
27751
+ return decodeURIComponent(s);
27752
+ } catch {
27753
+ return s;
27754
+ }
27755
+ }).join("/");
27756
+ return key.startsWith("chat/") ? { kind: "attachment", key } : null;
27757
+ }
27758
+ if (isExternalHref(href)) return null;
27759
+ const pathPart = href.split(/[?#]/)[0];
27760
+ if (!pathPart) return null;
27761
+ if (pathPart.startsWith("/")) {
27762
+ if (pathPart !== cwd && !pathPart.startsWith(`${cwd}/`)) return null;
27763
+ return { kind: "local", rel: pathPart.slice(cwd.length).replace(/^\/+/, "") };
27764
+ }
27765
+ return { kind: "local", rel: posix.normalize(docDir ? `${docDir}/${pathPart}` : pathPart) };
27766
+ }
27767
+ function readDocShareBundle({ cwd, sourcePath }) {
27768
+ const abs = resolveDocPath(cwd, sourcePath);
27769
+ if (!abs) return { status: "not-found" };
27770
+ const kind = shareKindOf(abs);
27771
+ if (!kind) return { status: "unsupported" };
27772
+ let stat;
27773
+ try {
27774
+ stat = statSync7(abs);
27775
+ } catch {
27776
+ return { status: "not-found" };
27777
+ }
27778
+ if (!stat.isFile()) return { status: "not-found" };
27779
+ if (stat.size > MAX_CONTENT_BYTES) return { status: "too-large" };
27780
+ const source = readFileSync14(abs, "utf8");
27781
+ const title = extractTitle(abs, kind === "markdown" ? "md" : kind);
27782
+ if (kind === "excalidraw") {
27783
+ try {
27784
+ const parsed = JSON.parse(source);
27785
+ if (!parsed || typeof parsed !== "object") return { status: "unsupported" };
27786
+ } catch {
27787
+ return { status: "unsupported" };
27788
+ }
27789
+ return { status: "ok", kind, title, content: source, assets: [] };
27790
+ }
27791
+ const docDir = sourcePath.includes("/") ? sourcePath.slice(0, sourcePath.lastIndexOf("/")) : "";
27792
+ const rewritten = /* @__PURE__ */ new Map();
27793
+ const usedNames = /* @__PURE__ */ new Set();
27794
+ const usedAnchors = /* @__PURE__ */ new Set();
27795
+ const assets = [];
27796
+ let assetBytes = 0;
27797
+ const attachments = [];
27798
+ let inlinedBytes = 0;
27799
+ const claimName = (candidate) => {
27800
+ const safe = sanitizeAssetName(candidate);
27801
+ if (!usedNames.has(safe)) {
27802
+ usedNames.add(safe);
27803
+ return safe;
27804
+ }
27805
+ const ext = extname2(safe);
27806
+ const stem = safe.slice(0, safe.length - ext.length);
27807
+ for (let n = 2; ; n += 1) {
27808
+ const next = `${stem}-${n}${ext}`;
27809
+ if (!usedNames.has(next)) {
27810
+ usedNames.add(next);
27811
+ return next;
27812
+ }
27813
+ }
27814
+ };
27815
+ const claimAnchor = (rel) => {
27816
+ const stem = sanitizeAssetName(rel).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
27817
+ const base = `file-${stem || "attachment"}`;
27818
+ if (!usedAnchors.has(base)) {
27819
+ usedAnchors.add(base);
27820
+ return base;
27821
+ }
27822
+ for (let n = 2; ; n += 1) {
27823
+ const next = `${base}-${n}`;
27824
+ if (!usedAnchors.has(next)) {
27825
+ usedAnchors.add(next);
27826
+ return next;
27827
+ }
27828
+ }
27829
+ };
27830
+ const refs = [];
27831
+ const hrefs = kind === "html" ? htmlUrls(source) : [...source.matchAll(MD_LINK)].map((m) => m[2]);
27832
+ for (const href of hrefs) {
27833
+ if (rewritten.has(href) || refs.some((r) => r.href === href)) continue;
27834
+ const ref = classifyHref(cwd, docDir, href);
27835
+ if (ref) refs.push({ href, ref });
27836
+ }
27837
+ for (const { href, ref } of refs.slice(0, MAX_ASSETS)) {
27838
+ if (ref.kind === "attachment") {
27839
+ const name2 = claimName(ref.key.split("/").pop() ?? "file");
27840
+ assets.push({ name: name2, copyFrom: ref.key });
27841
+ rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name2}`);
27842
+ continue;
27843
+ }
27844
+ const docAbs = kind === "markdown" ? resolveDocPath(cwd, ref.rel) : null;
27845
+ const lang = docAbs ? highlightLanguageOf(docAbs) : null;
27846
+ if (docAbs && lang) {
27847
+ const budget = Math.min(MAX_INLINE_BYTES, MAX_TOTAL_INLINE_BYTES - inlinedBytes);
27848
+ let text = null;
27849
+ try {
27850
+ const size = statSync7(docAbs).size;
27851
+ if (size <= budget) text = readFileSync14(docAbs, "utf8");
27852
+ } catch {
27853
+ continue;
27854
+ }
27855
+ if (text !== null) {
27856
+ const anchor = claimAnchor(ref.rel);
27857
+ inlinedBytes += Buffer.byteLength(text);
27858
+ attachments.push({ anchor, path: ref.rel, lang, text });
27859
+ rewritten.set(href, `#${anchor}`);
27860
+ continue;
27861
+ }
27862
+ }
27863
+ const resolved2 = resolveRawPath(cwd, ref.rel) ?? (docAbs ? { abs: docAbs, contentType: "text/plain; charset=utf-8" } : null);
27864
+ if (!resolved2) continue;
27865
+ let body;
27866
+ try {
27867
+ if (statSync7(resolved2.abs).size > MAX_ASSET_BYTES) continue;
27868
+ body = readFileSync14(resolved2.abs);
27869
+ } catch {
27870
+ continue;
27871
+ }
27872
+ assetBytes += body.length;
27873
+ if (assetBytes > MAX_BUNDLE_ASSET_BYTES) return { status: "too-large" };
27874
+ const name = claimName(ref.rel.split("/").pop() ?? "file");
27875
+ assets.push({ name, contentType: resolved2.contentType, data: body.toString("base64") });
27876
+ rewritten.set(href, `${SHARE_ASSET_PLACEHOLDER}${name}`);
27877
+ }
27878
+ if (kind === "html") {
27879
+ return { status: "ok", kind, title, content: rewriteHtml(source, rewritten), assets };
27880
+ }
27881
+ const content = source.replace(
27882
+ MD_LINK_FULL,
27883
+ (whole, bang, label, href, title2) => {
27884
+ const replacement = rewritten.get(href);
27885
+ if (replacement?.startsWith("#") && bang) return label;
27886
+ if (replacement) return `${bang}[${label}](${replacement}${title2})`;
27887
+ if (classifyHref(cwd, docDir, href)?.kind === "local") return label;
27888
+ return whole;
27889
+ }
27890
+ );
27891
+ return { status: "ok", kind, title, content: content + renderAttachments(attachments), assets };
27892
+ }
27893
+
27619
27894
  // src/store/doc-translation-store.ts
27620
27895
  async function getDocTranslation(channelId, sourcePath, lang, contentHash) {
27621
27896
  const { data, error } = await getSupabaseClient().from("doc_translations").select("title, content").eq("channel_id", channelId).eq("source_path", sourcePath).eq("lang", lang).eq("content_hash", contentHash).maybeSingle();
@@ -27682,6 +27957,8 @@ function rowToShare(row) {
27682
27957
  translationEnabled: row["translation_enabled"] === true,
27683
27958
  translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
27684
27959
  sourceLang: row["source_lang"] ?? null,
27960
+ // `not null default true`: only an explicit false turns it off.
27961
+ autoUpdate: row["auto_update"] !== false,
27685
27962
  audioKey: row["audio_key"] ?? null,
27686
27963
  audioStatus: row["audio_status"] ?? null,
27687
27964
  audioHash: row["audio_hash"] ?? null,
@@ -27721,7 +27998,22 @@ async function setDocShareSlug(id, slug) {
27721
27998
  if (error) throw new Error(`setDocShareSlug(${id}): ${error.message}`);
27722
27999
  return data ? rowToShare(data) : null;
27723
28000
  }
27724
- var SUMMARY_COLUMNS = "id, slug, tags, profile, channel_id, source_path, title, kind, created_by, created_at, updated_at, audio_enabled, ask_enabled, social_enabled, branding_enabled, translation_enabled, translation_langs, audio_status";
28001
+ async function setDocShareAutoUpdate(id, autoUpdate) {
28002
+ const { data, error } = await getSupabaseClient().from("doc_shares").update({ auto_update: autoUpdate }).eq("id", id).is("revoked_at", null).select("*").maybeSingle();
28003
+ if (error) throw new Error(`setDocShareAutoUpdate(${id}): ${error.message}`);
28004
+ return data ? rowToShare(data) : null;
28005
+ }
28006
+ async function listAutoUpdateDocShares(profiles) {
28007
+ let query = getSupabaseClient().from("doc_shares").select("channel_id, source_path").eq("auto_update", true).is("revoked_at", null);
28008
+ if (profiles !== null) query = query.in("profile", profiles);
28009
+ const { data, error } = await query;
28010
+ if (error) throw new Error(`listAutoUpdateDocShares: ${error.message}`);
28011
+ return (data ?? []).map((row) => ({
28012
+ channelId: row["channel_id"],
28013
+ sourcePath: row["source_path"]
28014
+ }));
28015
+ }
28016
+ var SUMMARY_COLUMNS = "id, slug, tags, profile, channel_id, source_path, title, kind, created_by, created_at, updated_at, audio_enabled, ask_enabled, social_enabled, branding_enabled, translation_enabled, translation_langs, auto_update, audio_status";
27725
28017
  function rowToSummary(row) {
27726
28018
  return {
27727
28019
  id: row["id"],
@@ -27740,6 +28032,7 @@ function rowToSummary(row) {
27740
28032
  askEnabled: row["ask_enabled"] !== false,
27741
28033
  socialEnabled: row["social_enabled"] === true,
27742
28034
  brandingEnabled: row["branding_enabled"] !== false,
28035
+ autoUpdate: row["auto_update"] !== false,
27743
28036
  translationEnabled: row["translation_enabled"] === true,
27744
28037
  translationLangs: Array.isArray(row["translation_langs"]) ? row["translation_langs"] : [],
27745
28038
  audioStatus: row["audio_status"] ?? null
@@ -28868,7 +29161,34 @@ function isDevHost(c) {
28868
29161
  );
28869
29162
  }
28870
29163
 
29164
+ // ../api/src/dashboard/admin-middleware.ts
29165
+ function platformAdminEmails() {
29166
+ const raw = process.env["PLATFORM_ADMIN_EMAILS"] ?? "";
29167
+ return new Set(
29168
+ raw.split(",").map((e) => e.trim().toLowerCase()).filter(Boolean)
29169
+ );
29170
+ }
29171
+ var requirePlatformOperator = async (c, next) => {
29172
+ const supabase = createRequestSupabaseClient(c);
29173
+ const {
29174
+ data: { user }
29175
+ } = await supabase.auth.getUser();
29176
+ if (!user?.email) return c.json({ error: "not signed in" }, 401);
29177
+ const email = user.email.trim().toLowerCase();
29178
+ if (!platformAdminEmails().has(email)) {
29179
+ return c.json({ error: "platform operator access required" }, 403);
29180
+ }
29181
+ c.set("platformOperator", { userId: user.id, email });
29182
+ return next();
29183
+ };
29184
+
28871
29185
  // ../api/src/dashboard/feature-flags-routes.ts
29186
+ function isOperator(auth) {
29187
+ return platformAdminEmails().has(auth.email.toLowerCase());
29188
+ }
29189
+ function isOperatorOnly(id) {
29190
+ return featureFlags[id].operatorOnly === true;
29191
+ }
28872
29192
  async function isFeatureEnabled(c, flagId) {
28873
29193
  const auth = c.get("auth");
28874
29194
  const enabled = await listEnabledFeatureFlags(auth.workspaceId);
@@ -28880,7 +29200,7 @@ function createFeatureFlagsRouter() {
28880
29200
  const auth = c.get("auth");
28881
29201
  const devHost = isDevHost(c);
28882
29202
  const flags = resolveFeatureFlags(await listEnabledFeatureFlags(auth.workspaceId), devHost);
28883
- const labs = featureFlagIds.filter((id) => isFeatureVisible(featureFlags[id].stage, devHost)).map((id) => ({ id, ...featureFlags[id], enabled: flags[id] }));
29203
+ const labs = featureFlagIds.filter((id) => isFeatureVisible(featureFlags[id].stage, devHost)).filter((id) => !isOperatorOnly(id) || isOperator(auth)).map((id) => ({ id, ...featureFlags[id], enabled: flags[id] }));
28884
29204
  return c.json({ flags, labs });
28885
29205
  });
28886
29206
  const toggle = async (c, enabled) => {
@@ -28888,6 +29208,9 @@ function createFeatureFlagsRouter() {
28888
29208
  if (auth.role !== "admin") return c.json({ error: "admin access required" }, 403);
28889
29209
  const flagId = c.req.param("flagId") ?? "";
28890
29210
  if (!isFeatureFlagId(flagId)) return c.json({ error: "unknown feature flag" }, 404);
29211
+ if (isOperatorOnly(flagId) && !isOperator(auth)) {
29212
+ return c.json({ error: "unknown feature flag" }, 404);
29213
+ }
28891
29214
  const stage = featureFlags[flagId].stage;
28892
29215
  if (stage !== "setting" && !isFeatureVisible(stage, isDevHost(c))) {
28893
29216
  return c.json({ error: "this feature flag cannot be changed here" }, 403);
@@ -28902,7 +29225,7 @@ function createFeatureFlagsRouter() {
28902
29225
  }
28903
29226
 
28904
29227
  // ../api/src/dashboard/public-share-routes.ts
28905
- import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "fs";
29228
+ import { existsSync as existsSync19, readFileSync as readFileSync16, statSync as statSync8 } from "fs";
28906
29229
  import { join as join20 } from "path";
28907
29230
  import { Hono as Hono3 } from "hono";
28908
29231
  import { GetObjectCommand as GetObjectCommand3 } from "@aws-sdk/client-s3";
@@ -29110,7 +29433,7 @@ function injectShareHead(html, head) {
29110
29433
 
29111
29434
  // ../api/src/dashboard/app-icon.ts
29112
29435
  import { createHash as createHash9 } from "crypto";
29113
- import { existsSync as existsSync18, readFileSync as readFileSync14 } from "fs";
29436
+ import { existsSync as existsSync18, readFileSync as readFileSync15 } from "fs";
29114
29437
  import { join as join19 } from "path";
29115
29438
  import sharp3 from "sharp";
29116
29439
  var PLATE = "#0A0A0F";
@@ -29139,7 +29462,7 @@ function roundedPlate(size, fill = PLATE) {
29139
29462
  }
29140
29463
  async function renderBadge(box) {
29141
29464
  const transparent = { r: 0, g: 0, b: 0, alpha: 0 };
29142
- const raster = await sharp3(readFileSync14(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
29465
+ const raster = await sharp3(readFileSync15(MARK_SVG_FILE)).resize(512, 512, { fit: "contain", background: transparent }).png().toBuffer();
29143
29466
  return sharp3(raster).trim().resize(box, box, { fit: "contain", background: transparent }).png().toBuffer();
29144
29467
  }
29145
29468
  async function sampleBackground(logo) {
@@ -29194,7 +29517,7 @@ async function renderAppIcon({
29194
29517
  if (hit) return hit;
29195
29518
  const out = logo && await composeIcon(logo, size, maskable, plain).catch(() => null) || // No workspace logo to lead with — the stock mark is still the best icon,
29196
29519
  // either on its usual dark plate or, for a favicon, trimmed and bare.
29197
- (transparent ? await renderBadge(size) : await sharp3(readFileSync14(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
29520
+ (transparent ? await renderBadge(size) : await sharp3(readFileSync15(MARK_FILE)).resize(size, size, { fit: "cover" }).png().toBuffer());
29198
29521
  cache4.set(key, out);
29199
29522
  return out;
29200
29523
  }
@@ -29731,9 +30054,9 @@ function createPublicShareApiRouter() {
29731
30054
  var BUILD_PREFIX = "/share/_assets";
29732
30055
  var shellCache = null;
29733
30056
  function readShell(path) {
29734
- const { mtimeMs } = statSync7(path);
30057
+ const { mtimeMs } = statSync8(path);
29735
30058
  if (shellCache?.mtimeMs === mtimeMs) return shellCache.html;
29736
- const html = readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
30059
+ const html = readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`);
29737
30060
  shellCache = { mtimeMs, html };
29738
30061
  return html;
29739
30062
  }
@@ -29758,12 +30081,12 @@ function serveBuildFile(c, webDist, dir, name) {
29758
30081
  c.header("Content-Type", type);
29759
30082
  c.header("Cache-Control", "public, max-age=31536000, immutable");
29760
30083
  if (ext === ".css") {
29761
- return c.body(readFileSync15(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
30084
+ return c.body(readFileSync16(path, "utf8").replaceAll("url(/fonts/", `url(${BUILD_PREFIX}/fonts/`));
29762
30085
  }
29763
30086
  if (ext === ".js") {
29764
- return c.body(readFileSync15(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
30087
+ return c.body(readFileSync16(path, "utf8").replaceAll('"/assets/', `"${BUILD_PREFIX}/`));
29765
30088
  }
29766
- return c.body(new Uint8Array(readFileSync15(path)));
30089
+ return c.body(new Uint8Array(readFileSync16(path)));
29767
30090
  }
29768
30091
  var HTML_SHARE_CSP = "sandbox allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox";
29769
30092
  function servePublishedHtml(c, share) {
@@ -29961,7 +30284,7 @@ ${analytics}` : head);
29961
30284
  }
29962
30285
 
29963
30286
  // src/dashboard/artifact-export.ts
29964
- import { readFileSync as readFileSync16 } from "fs";
30287
+ import { readFileSync as readFileSync17 } from "fs";
29965
30288
  async function exportDocAsArtifact(channelId, docPath) {
29966
30289
  const owningProfile = findOwningProfile(channelId);
29967
30290
  const channelConfig = await runWithProfile(
@@ -29970,7 +30293,7 @@ async function exportDocAsArtifact(channelId, docPath) {
29970
30293
  );
29971
30294
  const abs = resolveDocPath(channelConfig.cwd, docPath);
29972
30295
  if (!abs) throw new Error(`doc not found: ${docPath}`);
29973
- const content = readFileSync16(abs, "utf8");
30296
+ const content = readFileSync17(abs, "utf8");
29974
30297
  const title = extractTitle(abs, "md");
29975
30298
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
29976
30299
  const prompt = `Publish the document at \`${docPath}\` (already read below) as a Claude Artifact, then record the result as a stub file under this channel's \`docs/artifacts/\` folder (create the folder if it doesn't exist).
@@ -30084,7 +30407,7 @@ var CODE_EXTENSIONS = {
30084
30407
  ".gql": "graphql"
30085
30408
  };
30086
30409
  function highlightLanguageOf(path) {
30087
- const ext = extname2(path).toLowerCase();
30410
+ const ext = extname3(path).toLowerCase();
30088
30411
  const doc = DOC_EXTENSIONS[ext];
30089
30412
  if (doc) return doc === "md" ? "markdown" : doc === "excalidraw" ? "json" : "xml";
30090
30413
  return CODE_EXTENSIONS[ext] ?? null;
@@ -30117,7 +30440,7 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
30117
30440
  var MAX_ENTRIES = 500;
30118
30441
  var MAX_SEARCH_DEPTH = 6;
30119
30442
  var MAX_FLAT_DOCS = 2e3;
30120
- var MAX_CONTENT_BYTES = 2 * 1024 * 1024;
30443
+ var MAX_CONTENT_BYTES2 = 2 * 1024 * 1024;
30121
30444
  var TITLE_SCAN_BYTES = 8 * 1024;
30122
30445
  function byMtime(sort) {
30123
30446
  return (a, b) => {
@@ -30132,7 +30455,7 @@ function entryKind(entry, abs) {
30132
30455
  if (entry.isFile()) return "file";
30133
30456
  if (!entry.isSymbolicLink()) return null;
30134
30457
  try {
30135
- const target = statSync8(abs);
30458
+ const target = statSync9(abs);
30136
30459
  return target.isDirectory() ? "dir" : target.isFile() ? "file" : null;
30137
30460
  } catch {
30138
30461
  return null;
@@ -30140,12 +30463,12 @@ function entryKind(entry, abs) {
30140
30463
  }
30141
30464
  function fileNode(root, abs, name) {
30142
30465
  if (!isListableFile(name)) return null;
30143
- const ext = extname2(name).toLowerCase();
30466
+ const ext = extname3(name).toLowerCase();
30144
30467
  const kind = DOC_EXTENSIONS[ext];
30145
30468
  const lang = CODE_EXTENSIONS[ext];
30146
30469
  let stat;
30147
30470
  try {
30148
- stat = statSync8(abs);
30471
+ stat = statSync9(abs);
30149
30472
  } catch {
30150
30473
  return null;
30151
30474
  }
@@ -30208,7 +30531,7 @@ function resolveDirPath(root, rel) {
30208
30531
  }
30209
30532
  function isListableFile(name) {
30210
30533
  if (SKIP_FILES.has(name)) return false;
30211
- const ext = extname2(name).toLowerCase();
30534
+ const ext = extname3(name).toLowerCase();
30212
30535
  return ext in DOC_EXTENSIONS || ext in CODE_EXTENSIONS || ASSET_LIST_EXTENSIONS.has(ext);
30213
30536
  }
30214
30537
  var HAS_DOCS_BUDGET = 4e3;
@@ -30251,13 +30574,13 @@ function probeDir(absDir, showHidden) {
30251
30574
  function readGitBranch(dir) {
30252
30575
  try {
30253
30576
  let gitDir = join21(dir, ".git");
30254
- if (statSync8(gitDir).isFile()) {
30255
- const pointer = readFileSync17(gitDir, "utf8").trim();
30577
+ if (statSync9(gitDir).isFile()) {
30578
+ const pointer = readFileSync18(gitDir, "utf8").trim();
30256
30579
  const match = pointer.match(/^gitdir:\s*(.+)$/);
30257
30580
  if (!match) return void 0;
30258
30581
  gitDir = resolve7(dir, match[1]);
30259
30582
  }
30260
- const head = readFileSync17(join21(gitDir, "HEAD"), "utf8").trim();
30583
+ const head = readFileSync18(join21(gitDir, "HEAD"), "utf8").trim();
30261
30584
  const branchMatch = head.match(/^ref:\s*refs\/heads\/(.+)$/);
30262
30585
  if (branchMatch) return branchMatch[1];
30263
30586
  return /^[0-9a-f]{7,40}$/i.test(head) ? head.slice(0, 7) : void 0;
@@ -30344,7 +30667,7 @@ function resolveDocPath(root, rel) {
30344
30667
  if (!rel || rel.includes("\0")) return null;
30345
30668
  const abs = resolve7(root, rel);
30346
30669
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30347
- const ext = extname2(abs).toLowerCase();
30670
+ const ext = extname3(abs).toLowerCase();
30348
30671
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return null;
30349
30672
  return abs;
30350
30673
  }
@@ -30353,7 +30676,7 @@ function writeDocContent(root, rel, content, baseMtime) {
30353
30676
  if (!abs) return { status: "not-found" };
30354
30677
  let stat;
30355
30678
  try {
30356
- stat = statSync8(abs);
30679
+ stat = statSync9(abs);
30357
30680
  } catch {
30358
30681
  return { status: "not-found" };
30359
30682
  }
@@ -30361,17 +30684,17 @@ function writeDocContent(root, rel, content, baseMtime) {
30361
30684
  if (baseMtime && stat.mtime.toISOString() !== baseMtime) {
30362
30685
  return { status: "conflict", mtime: stat.mtime.toISOString() };
30363
30686
  }
30364
- if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) {
30687
+ if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) {
30365
30688
  return { status: "too-large" };
30366
30689
  }
30367
30690
  writeFileSync7(abs, content, "utf8");
30368
- return { status: "ok", mtime: statSync8(abs).mtime.toISOString() };
30691
+ return { status: "ok", mtime: statSync9(abs).mtime.toISOString() };
30369
30692
  }
30370
30693
  function resolveRawPath(root, rel) {
30371
30694
  if (!rel || rel.includes("\0")) return null;
30372
30695
  const abs = resolve7(root, rel);
30373
30696
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30374
- const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()];
30697
+ const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()];
30375
30698
  if (!contentType) return null;
30376
30699
  return { abs, contentType };
30377
30700
  }
@@ -30379,7 +30702,7 @@ function resolveHtmlPath(root, rel) {
30379
30702
  if (!rel || rel.includes("\0")) return null;
30380
30703
  const abs = resolve7(root, rel);
30381
30704
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30382
- if (DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "html") return null;
30705
+ if (DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "html") return null;
30383
30706
  return abs;
30384
30707
  }
30385
30708
  function resolveDownloadPath(root, rel) {
@@ -30387,7 +30710,7 @@ function resolveDownloadPath(root, rel) {
30387
30710
  const abs = resolve7(root, rel);
30388
30711
  if (abs !== root && !abs.startsWith(root + sep4)) return null;
30389
30712
  if (!isListableFile(basename6(abs))) return null;
30390
- const contentType = MEDIA_EXTENSIONS[extname2(abs).toLowerCase()] ?? "application/octet-stream";
30713
+ const contentType = MEDIA_EXTENSIONS[extname3(abs).toLowerCase()] ?? "application/octet-stream";
30391
30714
  return { abs, contentType };
30392
30715
  }
30393
30716
  function sanitizeUploadName(name) {
@@ -30397,12 +30720,12 @@ function sanitizeUploadName(name) {
30397
30720
  return cleaned.slice(-120);
30398
30721
  }
30399
30722
  function uniqueName(absDir, name) {
30400
- const ext = extname2(name);
30723
+ const ext = extname3(name);
30401
30724
  const stem = name.slice(0, name.length - ext.length);
30402
30725
  let candidate = name;
30403
30726
  for (let n = 1; n < 1e3; n++) {
30404
30727
  try {
30405
- statSync8(join21(absDir, candidate));
30728
+ statSync9(join21(absDir, candidate));
30406
30729
  } catch {
30407
30730
  return candidate;
30408
30731
  }
@@ -30414,13 +30737,13 @@ function saveUploadedFile(root, relDir, name, data) {
30414
30737
  const absDir = resolveDirPath(root, relDir);
30415
30738
  if (absDir === null) return { status: "no-dir" };
30416
30739
  try {
30417
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30740
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30418
30741
  } catch {
30419
30742
  return { status: "no-dir" };
30420
30743
  }
30421
30744
  const safe = sanitizeUploadName(name);
30422
30745
  if (!safe) return { status: "bad-name" };
30423
- const ext = extname2(safe).toLowerCase();
30746
+ const ext = extname3(safe).toLowerCase();
30424
30747
  if (!(ext in DOC_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) return { status: "bad-type" };
30425
30748
  if (data.byteLength > MAX_UPLOAD_BYTES) return { status: "too-large" };
30426
30749
  const final = uniqueName(absDir, safe);
@@ -30432,7 +30755,7 @@ function createDocFolder(root, relDir, name) {
30432
30755
  const absDir = resolveDirPath(root, relDir);
30433
30756
  if (absDir === null) return { status: "no-dir" };
30434
30757
  try {
30435
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30758
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30436
30759
  } catch {
30437
30760
  return { status: "no-dir" };
30438
30761
  }
@@ -30440,7 +30763,7 @@ function createDocFolder(root, relDir, name) {
30440
30763
  if (!safe) return { status: "bad-name" };
30441
30764
  const abs = join21(absDir, safe);
30442
30765
  try {
30443
- statSync8(abs);
30766
+ statSync9(abs);
30444
30767
  return { status: "exists" };
30445
30768
  } catch {
30446
30769
  }
@@ -30451,16 +30774,16 @@ function createDocFile(root, relDir, name, content) {
30451
30774
  const absDir = resolveDirPath(root, relDir);
30452
30775
  if (absDir === null) return { status: "no-dir" };
30453
30776
  try {
30454
- if (!statSync8(absDir).isDirectory()) return { status: "no-dir" };
30777
+ if (!statSync9(absDir).isDirectory()) return { status: "no-dir" };
30455
30778
  } catch {
30456
30779
  return { status: "no-dir" };
30457
30780
  }
30458
30781
  const safe = sanitizeUploadName(name);
30459
30782
  if (!safe) return { status: "bad-name" };
30460
- const ext = extname2(safe).toLowerCase();
30783
+ const ext = extname3(safe).toLowerCase();
30461
30784
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS)) return { status: "bad-name" };
30462
30785
  if (SKIP_FILES.has(safe)) return { status: "bad-name" };
30463
- if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES) return { status: "too-large" };
30786
+ if (Buffer.byteLength(content, "utf8") > MAX_CONTENT_BYTES2) return { status: "too-large" };
30464
30787
  const abs = join21(absDir, safe);
30465
30788
  try {
30466
30789
  writeFileSync7(abs, content, { encoding: "utf8", flag: "wx" });
@@ -30476,7 +30799,7 @@ function moveDocEntry(root, from, to) {
30476
30799
  if (!absFrom.startsWith(root + sep4)) return { status: "not-found" };
30477
30800
  let stat;
30478
30801
  try {
30479
- stat = statSync8(absFrom);
30802
+ stat = statSync9(absFrom);
30480
30803
  } catch {
30481
30804
  return { status: "not-found" };
30482
30805
  }
@@ -30487,7 +30810,7 @@ function moveDocEntry(root, from, to) {
30487
30810
  const name = sanitizeUploadName(basename6(absTo));
30488
30811
  if (!name) return { status: "bad-target" };
30489
30812
  if (!isDir) {
30490
- const ext = extname2(name).toLowerCase();
30813
+ const ext = extname3(name).toLowerCase();
30491
30814
  if (!(ext in DOC_EXTENSIONS) && !(ext in CODE_EXTENSIONS) && !ASSET_LIST_EXTENSIONS.has(ext)) {
30492
30815
  return { status: "bad-target" };
30493
30816
  }
@@ -30495,7 +30818,7 @@ function moveDocEntry(root, from, to) {
30495
30818
  const absToDir = dirname3(absTo);
30496
30819
  if (resolveDirPath(root, relative2(root, absToDir)) === null) return { status: "bad-target" };
30497
30820
  try {
30498
- if (!statSync8(absToDir).isDirectory()) return { status: "bad-target" };
30821
+ if (!statSync9(absToDir).isDirectory()) return { status: "bad-target" };
30499
30822
  } catch {
30500
30823
  return { status: "bad-target" };
30501
30824
  }
@@ -30555,7 +30878,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30555
30878
  if (!resolved2) return c.json({ error: "not found" }, 404);
30556
30879
  let stat;
30557
30880
  try {
30558
- stat = statSync8(resolved2.abs);
30881
+ stat = statSync9(resolved2.abs);
30559
30882
  } catch {
30560
30883
  return c.json({ error: "not found" }, 404);
30561
30884
  }
@@ -30577,13 +30900,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30577
30900
  if (!abs) return c.json({ error: "not found" }, 404);
30578
30901
  let stat;
30579
30902
  try {
30580
- stat = statSync8(abs);
30903
+ stat = statSync9(abs);
30581
30904
  } catch {
30582
30905
  return c.json({ error: "not found" }, 404);
30583
30906
  }
30584
30907
  if (!stat.isFile()) return c.json({ error: "not found" }, 404);
30585
30908
  if (stat.size > MAX_RAW_BYTES) return c.json({ error: "file too large" }, 413);
30586
- return c.body(withDocLinkBridge(readFileSync17(abs, "utf8")), 200, {
30909
+ const html = inlinePreviewImages(cwd, c.req.query("path") ?? "", readFileSync18(abs, "utf8"));
30910
+ return c.body(withDocLinkBridge(html), 200, {
30587
30911
  "Content-Type": "text/html; charset=utf-8",
30588
30912
  "Content-Security-Policy": HTML_SHARE_CSP,
30589
30913
  "X-Content-Type-Options": "nosniff",
@@ -30701,11 +31025,11 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30701
31025
  if (!abs) return c.json({ error: "not found" }, 404);
30702
31026
  let stat;
30703
31027
  try {
30704
- stat = statSync8(abs);
31028
+ stat = statSync9(abs);
30705
31029
  } catch {
30706
31030
  return c.json({ error: "not found" }, 404);
30707
31031
  }
30708
- if (!stat.isFile() || DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "md") {
31032
+ if (!stat.isFile() || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
30709
31033
  return c.json({ error: "not a markdown doc" }, 400);
30710
31034
  }
30711
31035
  void exportDocAsArtifact(channelId, rel).catch((err) => {
@@ -30750,14 +31074,14 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30750
31074
  if (!abs) return c.json({ error: "not found" }, 404);
30751
31075
  let stat;
30752
31076
  try {
30753
- stat = statSync8(abs);
31077
+ stat = statSync9(abs);
30754
31078
  } catch {
30755
31079
  return c.json({ error: "not found" }, 404);
30756
31080
  }
30757
31081
  if (!stat.isFile()) return c.json({ error: "not found" }, 404);
30758
- const ext = extname2(abs).toLowerCase();
31082
+ const ext = extname3(abs).toLowerCase();
30759
31083
  const kind = DOC_EXTENSIONS[ext];
30760
- const tooLarge = stat.size > MAX_CONTENT_BYTES;
31084
+ const tooLarge = stat.size > MAX_CONTENT_BYTES2;
30761
31085
  if (tooLarge && kind !== "html") return c.json({ error: "file too large" }, 413);
30762
31086
  return c.json({
30763
31087
  path: rel,
@@ -30768,7 +31092,7 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30768
31092
  title: kind ? extractTitle(abs, kind) : basename6(abs),
30769
31093
  mtime: stat.mtime.toISOString(),
30770
31094
  tooLarge: tooLarge || void 0,
30771
- content: tooLarge ? "" : readFileSync17(abs, "utf8")
31095
+ content: tooLarge ? "" : readFileSync18(abs, "utf8")
30772
31096
  });
30773
31097
  });
30774
31098
  app.put("/:id/docs/content", async (c) => {
@@ -30796,22 +31120,22 @@ function createDocsRouter({ gate = requireDocsAccess } = {}) {
30796
31120
  if (!channel) return { error: c.json({ error: "channel not found" }, 404) };
30797
31121
  const rel = c.req.query("path") ?? "";
30798
31122
  const abs = resolveDocPath(channel.cwd, rel);
30799
- if (!abs || DOC_EXTENSIONS[extname2(abs).toLowerCase()] !== "md") {
31123
+ if (!abs || DOC_EXTENSIONS[extname3(abs).toLowerCase()] !== "md") {
30800
31124
  return { error: c.json({ error: "not found" }, 404) };
30801
31125
  }
30802
31126
  let stat;
30803
31127
  try {
30804
- stat = statSync8(abs);
31128
+ stat = statSync9(abs);
30805
31129
  } catch {
30806
31130
  return { error: c.json({ error: "not found" }, 404) };
30807
31131
  }
30808
31132
  if (!stat.isFile()) return { error: c.json({ error: "not found" }, 404) };
30809
- if (stat.size > MAX_CONTENT_BYTES) return { error: c.json({ error: "file too large" }, 413) };
31133
+ if (stat.size > MAX_CONTENT_BYTES2) return { error: c.json({ error: "file too large" }, 413) };
30810
31134
  return {
30811
31135
  channel,
30812
31136
  rel,
30813
31137
  title: extractTitle(abs, "md"),
30814
- content: readFileSync17(abs, "utf8")
31138
+ content: readFileSync18(abs, "utf8")
30815
31139
  };
30816
31140
  };
30817
31141
  app.get("/:id/docs/translation/:lang", async (c) => {
@@ -30871,7 +31195,7 @@ function isRealDoc(root, rel) {
30871
31195
  const abs = resolveDocPath(root, rel);
30872
31196
  if (!abs || !existsSync21(abs)) return false;
30873
31197
  try {
30874
- return statSync9(abs).isFile();
31198
+ return statSync10(abs).isFile();
30875
31199
  } catch {
30876
31200
  return false;
30877
31201
  }
@@ -30924,6 +31248,82 @@ function slackMrkdwnToMarkdown(text) {
30924
31248
  return resolveSlackTokens(text).replace(/(?<![\w*])\*(?!\*)(\S(?:[^*\n]*?\S)?)\*(?!\*)(?![\w*])/g, "**$1**").replace(/(?<![\w~])~(?!~)(\S(?:[^~\n]*?\S)?)~(?!~)(?![\w~])/g, "~~$1~~").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
30925
31249
  }
30926
31250
 
31251
+ // ../api/src/dashboard/support-guide.ts
31252
+ var GUIDE_ANCHORS = {
31253
+ "sidebar.add-channel": 'any /chat page: "+" next to Channels, creates a channel or category',
31254
+ "header.workspace-switcher": "any page: switch or create a workspace",
31255
+ "header.settings": "any page: opens workspace settings",
31256
+ "header.account": "any page: account menu (profile, theme, log out)",
31257
+ "thread.new": "any /chat page: start a new thread (topic)",
31258
+ "thread.status": "open thread: set the thread status",
31259
+ "channel.docs": "channel page: open this channel's docs",
31260
+ "composer.send": "message composer: send",
31261
+ "composer.attach": "message composer: attach a file",
31262
+ "composer.dictate": "message composer: dictate by voice",
31263
+ "composer.model": "message composer: pick the agent model and effort",
31264
+ "docs.upload": "docs pane: upload files to the channel folder",
31265
+ "docs.new-doc": "docs pane: new doc in the channel folder",
31266
+ "members.invite": "/settings/members: invite a member by email (admins only)"
31267
+ };
31268
+ var SETTINGS_SECTIONS = [
31269
+ "general",
31270
+ "agent",
31271
+ "prompt",
31272
+ "models",
31273
+ "labs",
31274
+ "auto-topic",
31275
+ "output-styles",
31276
+ "skills",
31277
+ "memory",
31278
+ "members",
31279
+ "connections",
31280
+ "automations",
31281
+ "activity",
31282
+ "channels",
31283
+ "domain",
31284
+ "workspaces",
31285
+ "usage",
31286
+ "sessions",
31287
+ "mcp-servers",
31288
+ "logs"
31289
+ ];
31290
+ for (const s of SETTINGS_SECTIONS) GUIDE_ANCHORS[`settings.${s}`] = `/settings/*: the ${s} tab`;
31291
+ var GUIDE_ROUTES = {
31292
+ "/chat": "chat home, channel list",
31293
+ "/chat/threads": "all threads in the workspace",
31294
+ "/chat/search": "search",
31295
+ "/chat/archive": "archived threads",
31296
+ "/chat/docs": "shared doc links",
31297
+ ...Object.fromEntries(SETTINGS_SECTIONS.map((s) => [`/settings/${s}`, `settings: ${s}`]))
31298
+ };
31299
+ var GUIDE_RULES = `
31300
+ On-screen guide: whenever the answer tells the user where to click or which page to open and a route or anchor below matches, end your reply with one line:
31301
+ <guide>{"navigate": <route or null>, "steps": [{"action": "guide" | "highlight", "anchor": "<anchor id>", "say": "<a few words>"}]}</guide>
31302
+ - navigate: a route from the list below to open first, or null to stay on the current page. The steps then run on that page, so never point at the button that leads to it.
31303
+ - steps: at most 3, in order, anchors from the list only, never invented. "guide" waits for the user to click it; use "highlight" for the last step when it only shows where something is. "say" uses the reply's language.
31304
+ - Leave the guide out when nothing below fits. Never mention the guide or anchor ids in the answer text.
31305
+ Routes:
31306
+ ${Object.entries(GUIDE_ROUTES).map(([r, d]) => `- ${r}: ${d}`).join("\n")}
31307
+ Anchors:
31308
+ ${Object.entries(GUIDE_ANCHORS).map(([a, d]) => `- ${a}: ${d}`).join("\n")}
31309
+ `;
31310
+ var GUIDE_RE = /<guide>([\s\S]*?)<\/guide>/;
31311
+ function extractGuide(text) {
31312
+ const match = text.match(GUIDE_RE);
31313
+ if (!match) return { answer: text, guide: null };
31314
+ const answer = text.replace(match[0], "").trim();
31315
+ try {
31316
+ const raw = JSON.parse(match[1]);
31317
+ const navigate = typeof raw.navigate === "string" && raw.navigate in GUIDE_ROUTES ? raw.navigate : null;
31318
+ const steps = (Array.isArray(raw.steps) ? raw.steps : []).filter(
31319
+ (s) => !!s && (s.action === "guide" || s.action === "highlight") && typeof s.anchor === "string" && s.anchor in GUIDE_ANCHORS && typeof s.say === "string"
31320
+ ).slice(0, 3).map(({ action, anchor, say }) => ({ action, anchor, say: say.slice(0, 200) }));
31321
+ return { answer, guide: navigate || steps.length ? { navigate, steps } : null };
31322
+ } catch {
31323
+ return { answer, guide: null };
31324
+ }
31325
+ }
31326
+
30927
31327
  // ../api/src/dashboard/support-bot.ts
30928
31328
  var GROQ_API_URL7 = "https://api.groq.com/openai/v1/chat/completions";
30929
31329
  var SUPPORT_MODEL = "openai/gpt-oss-120b";
@@ -31004,13 +31404,14 @@ async function recordEvent(row) {
31004
31404
  const { error } = await getSupabaseClient().from("support_events").insert(row);
31005
31405
  if (error) console.error("support_events insert failed:", error.message);
31006
31406
  }
31007
- async function postReply(threadId, body, offerHuman = false) {
31407
+ async function postReply(threadId, body, offerHuman = false, guide = null) {
31008
31408
  const { data, error } = await getSupabaseClient().from("thread_replies").insert({
31009
31409
  thread_id: threadId,
31010
31410
  author: SUPPORT_BOT_AUTHOR,
31011
31411
  author_kind: "support_bot",
31012
31412
  body,
31013
- ...offerHuman ? { support_escalation: "offered" } : {}
31413
+ ...offerHuman ? { support_escalation: "offered" } : {},
31414
+ ...guide ? { guide } : {}
31014
31415
  }).select("id").single();
31015
31416
  if (error) throw new Error(`support reply insert: ${error.message}`);
31016
31417
  return data.id;
@@ -31074,7 +31475,8 @@ async function handleSupportMention(trigger, deps = {}) {
31074
31475
  // cache can reuse them; the per-thread content goes last.
31075
31476
  messages: [
31076
31477
  { role: "system", content: `${RULES}${docs}
31077
- </docs>` },
31478
+ </docs>
31479
+ ${GUIDE_RULES}` },
31078
31480
  {
31079
31481
  role: "user",
31080
31482
  content: `<environment>
@@ -31085,7 +31487,7 @@ ${env}
31085
31487
  ${transcript}
31086
31488
  </thread>
31087
31489
 
31088
- Answer the latest @support mention, from ${trigger.author}.`
31490
+ Answer the latest @support mention, from ${trigger.author}. Add the <guide> line when the answer points at something in the UI.`
31089
31491
  }
31090
31492
  ]
31091
31493
  })
@@ -31093,7 +31495,8 @@ Answer the latest @support mention, from ${trigger.author}.`
31093
31495
  if (!res.ok) throw new Error(`Groq ${res.status}: ${(await res.text()).slice(0, 300)}`);
31094
31496
  const data = await res.json();
31095
31497
  const text = (data.choices?.[0]?.message?.content ?? "").trim();
31096
- const answer = text.replaceAll(NO_DOC_MARKER, "").trim();
31498
+ const { answer: withMarker, guide } = extractGuide(text);
31499
+ const answer = withMarker.replaceAll(NO_DOC_MARKER, "").trim();
31097
31500
  const noDoc = text.includes(NO_DOC_MARKER) || citedDocs(answer).length === 0;
31098
31501
  event = {
31099
31502
  ...event,
@@ -31105,7 +31508,12 @@ Answer the latest @support mention, from ${trigger.author}.`
31105
31508
  };
31106
31509
  if (!answer)
31107
31510
  throw new Error(`empty answer (finish_reason ${data.choices?.[0]?.finish_reason})`);
31108
- event.reply_id = await postReply(trigger.threadId, answer, noDoc || wantsHuman(trigger.body));
31511
+ event.reply_id = await postReply(
31512
+ trigger.threadId,
31513
+ answer,
31514
+ noDoc || wantsHuman(trigger.body),
31515
+ guide
31516
+ );
31109
31517
  } catch (err) {
31110
31518
  console.error("Support bot answer failed:", err);
31111
31519
  if (!event.reply_id) {
@@ -32437,6 +32845,10 @@ ${msg.body}` : expandSkillCommand(channelConfig.claudeConfigDir, channelConfig.c
32437
32845
  args: ["mcp", "threads"],
32438
32846
  env: {
32439
32847
  FLYSPACE_THREADS_WORKSPACE: channelConfig.profile,
32848
+ ...channelConfig.permissionThread ? {
32849
+ FLYSPACE_THREAD_ID: channelConfig.permissionThread.threadId,
32850
+ FLYSPACE_CHANNEL_ID: channelConfig.permissionThread.channelId
32851
+ } : {},
32440
32852
  ...channelConfig.requesterHandle ? { FLYSPACE_REQUESTER_HANDLE: channelConfig.requesterHandle } : {}
32441
32853
  }
32442
32854
  },
@@ -35237,9 +35649,14 @@ export {
35237
35649
  resolveDocsAccess,
35238
35650
  filterReadableDocsChannels,
35239
35651
  requireDocsAccess,
35652
+ watchDocs,
35653
+ SHARE_ASSET_PLACEHOLDER,
35654
+ readDocShareBundle,
35240
35655
  DocShareSlugTakenError,
35241
35656
  isSlugAvailable,
35242
35657
  setDocShareSlug,
35658
+ setDocShareAutoUpdate,
35659
+ listAutoUpdateDocShares,
35243
35660
  listLiveDocShares,
35244
35661
  findDocShareBySource,
35245
35662
  createDocShare,
@@ -35261,6 +35678,8 @@ export {
35261
35678
  workspaceHostname,
35262
35679
  trustedHost,
35263
35680
  isDevHost,
35681
+ platformAdminEmails,
35682
+ requirePlatformOperator,
35264
35683
  isFeatureEnabled,
35265
35684
  createFeatureFlagsRouter,
35266
35685
  PLATE,
@@ -35268,11 +35687,7 @@ export {
35268
35687
  clientKey,
35269
35688
  createPublicShareApiRouter,
35270
35689
  createPublicShareAssetRouter,
35271
- highlightLanguageOf,
35272
- extractTitle,
35273
35690
  flatDocs,
35274
- resolveDocPath,
35275
- resolveRawPath,
35276
35691
  createDocsRouter,
35277
35692
  slackMrkdwnToMarkdown,
35278
35693
  handleSupportMention,